package com.itheima.mapper;


import com.itheima.entity.Emp;
import com.itheima.entity.EmpExpr;
import com.itheima.entity.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

    /**
     * 统计员工总数
     * @return
     */

//    @Select("select count(*) from emp")
//    Long count();

    /**
     * 分页查询员工数据
     * @param start
     * @param pageSize
     * @return
     */

//    @Select("select e.*,d.name as deptName from emp e join dept d on e.dept_id=d.id limit #{start},#{pageSize}")
//    List<Emp> page(Integer start, Integer pageSize);


    /**
     * 列表查询
     * @return
     */

//    @Select("select e.*,d.name as deptName from emp e join dept d on e.dept_id=d.id ")

    //基于xml开发动态SQL
    List<Emp> list(EmpQueryParam param);


    /**
     *调用mapper，保存员工的基本信息到emp表
     * @param emp
     */

    @Options(useGeneratedKeys = true,keyProperty ="id")   //获取主键的值并赋给id属性
    @Insert("insert into emp values (null, #{username}, #{password}, #{name},#{gender}, #{phone}," +
            " #{job}, #{salary},#{image},#{entryDate},#{deptId}, #{createTime}, #{updateTime})")
    void insert(Emp emp);

    /**
     * 批量删除员工  动态sql
     * @param ids
     */
    void deleteBatch(List<Integer> ids);

    /**
     * 根据id查询员工信息以及经历列表信息
     * @param id
     * @return
     */
   // @Select("select * from emp e join dept d on e.dept_id=d.id where e.id=#{id}")

    Emp getById(Integer id);

    /**
     * 根据id查询员工基本信息
     * @param id
     * @return
     */
    @Select("select * from emp where id=#{id}")
    Emp getById2(Integer id);

    /**
     * 更新员工信息
     * @param emp
     */
    void update(Emp emp);

    /**
     * 根据用户名和密码查询员工---登录
     * @param emp
     * @return
     */
    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp selectUsernameAndPassword(Emp emp);
}














































